package com.ruoyi.iot.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.iot.domain.FacDevicesRundata;
import com.ruoyi.iot.service.IFacDevicesRundataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备运行数据信息Controller
 * 
 * @author rww
 * @date 2024-06-24
 */
@RestController
@RequestMapping("/iot/rundata")
public class FacDevicesRundataController extends BaseController
{
    @Autowired
    private IFacDevicesRundataService facDevicesRundataService;

    /**
     * 查询设备运行数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:list')")
    @GetMapping("/list")
    public TableDataInfo list(FacDevicesRundata facDevicesRundata)
    {
        startPage();
        List<FacDevicesRundata> list = facDevicesRundataService.selectFacDevicesRundataList(facDevicesRundata);
        return getDataTable(list);
    }

    /**
     * 查询设不允许数据信息列表-不带分页
     * @param facDevicesRundata
     * @return
     */
    @GetMapping("/noPageList")
    public AjaxResult noPageList(FacDevicesRundata facDevicesRundata)
    {
        List<FacDevicesRundata> list = facDevicesRundataService.selectFacDevicesRundataList(facDevicesRundata);
        return AjaxResult.success(list);
    }

    /**
     * 导出设备运行数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:export')")
    @Log(title = "设备运行数据信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FacDevicesRundata facDevicesRundata)
    {
        List<FacDevicesRundata> list = facDevicesRundataService.selectFacDevicesRundataList(facDevicesRundata);
        ExcelUtil<FacDevicesRundata> util = new ExcelUtil<FacDevicesRundata>(FacDevicesRundata.class);
        util.exportExcel(response, list, "设备运行数据信息数据");
    }

    /**
     * 获取设备运行数据信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(facDevicesRundataService.selectFacDevicesRundataById(id));
    }

    /**
     * 新增设备运行数据信息
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:add')")
    @Log(title = "设备运行数据信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FacDevicesRundata facDevicesRundata)
    {
        return toAjax(facDevicesRundataService.insertFacDevicesRundata(facDevicesRundata));
    }

    /**
     * 修改设备运行数据信息
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:edit')")
    @Log(title = "设备运行数据信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FacDevicesRundata facDevicesRundata)
    {
        return toAjax(facDevicesRundataService.updateFacDevicesRundata(facDevicesRundata));
    }

    /**
     * 删除设备运行数据信息
     */
    @PreAuthorize("@ss.hasPermi('iot:rundata:remove')")
    @Log(title = "设备运行数据信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(facDevicesRundataService.deleteFacDevicesRundataByIds(ids));
    }
}
